import { Component, OnInit, Input } from '@angular/core';
import { AppGlobalService } from '../../shared/service/app-global.service';

@Component({
    selector: 'app-help-transfer-siting',
    templateUrl: './help-transfer-siting.component.html',
    styleUrls: ['./help-transfer-siting.component.scss']
})
export class HelpTransferSitingComponent implements OnInit {

    @Input() tagData: any;
    showFlag: boolean;       // true:tagData.hasData; false: tagData.noData
    pageData: any;
    sessionId: string;
    defaultImg: string;
    pageStyle: string;
    constructor(private appGlobalService: AppGlobalService) { }

    ngOnInit() {
        this.sessionId = localStorage.getItem('sessionId');
        this.defaultImg = '../../../assets/img/default_img.png';
        this.pageStyle = this.tagData.data.cssStyle === 'blue' ? 'bluetStyle' : 'orangeStyle';
        if (this.tagData.data.hasData) {
            this.showFlag = true;
            this.pageData = this.tagData.data.hasData;
        } else if (this.tagData.data.noData) {
            this.showFlag = false;
            this.pageData = this.tagData.data.noData;
        }
    }

    go(obj) {
        const pageParams = {
            pageId: obj.target,
            params: obj.params,
            sessionId: localStorage.getItem('sessionId')
        };
        this.appGlobalService.goToForward(pageParams);
    }

}
